package iscript.coreFramework.data.pager 
{
	/**
	 * ...
	 * @author raymond
	 */
	public class ArrayPager extends BasePager
	{
		
		public function ArrayPager(record:Array) 
		{
			_datasource = record;
			super(record.length);
		}
	  
		private var _datasource:Array = new Array();	
		
		public  function get dataSource():Array { return _datasource; }
		
		
		override public function get recordCount():int 
		{
			return _datasource.length;
		}
		
		
		override public function get pageCount():int 
		{
			var pageCount:int = 0;			   
			   if (recordCount % pageSize == 0) {
				   pageCount = recordCount/pageSize
				   }else {
				   pageCount = recordCount/pageSize+1
				}
			    return  pageCount;
		}
		
		
		public  function getDataByPageIndex(pageIndex:int):Array {
			 var  number:Array = this.getNumberByPageIndex(pageIndex);
			 var data:Array = new Array();
			 for each(var i:* in number) {
			   data.push(_datasource[i]);
			 }
			  return data;
			 
			}
			
			
		public 	 function  getDataByCurrentPage():Array {
			var  number:Array = this.getNumberByCurrentPage();
			var data:Array = new Array();
			 for each(var i:* in number) {
			   data.push(_datasource[i]);
			 }
			  return data;
		     }
		
		
	}

}